If...Then...Else

General Control Statement

Syntax samples

IF <Boolean expression> THEN <statement 1> {ELSE <statement 2>}

 

IF Var1 = 5 THEN WAIT 2 min

 

IF (Attr2 = 5) OR (Var5 <> 0) THEN WAIT 2 min ELSE WAIT 3 min

 

IF Var1 > Attr2 THEN
BEGIN
Var1 = Attr2
WAIT Attr1
END
ELSE
BEGIN
INC Var1
WAIT Attr2
END

Description

Executes a statement or statement block if the Boolean expression is true. If an ELSE statement is included and the Boolean expression is false, an alternate statement or statement block is executed. For an IF...THEN statement to be broken into more than one line, the first item on the next line must be THEN, AND, or OR. IF...THEN statements only apply to the next statement or statement block in a logic. Any statements outside of the BEGIN and END will execute normally. See BEGIN and END for examples.

Valid In

Any logic.

Components

<Boolean expression>

The condition to be tested.

THEN <statement 1>

The statement or block to be executed if the condition is true.

ELSE <statement 2>

The statement or block to be executed if the condition is false.

Example

In the following example an IF...THEN...ELSE test is made to see if the simulation clock is less than eight hours. If so, the Client is routed to Office1, otherwise the Client is routed to Office2.

Process Table

Entity

Location

Operation (min)

Client

Loc1

IF CLOCK(Hr) < 8 THEN

ROUTE 1

ELSE

ROUTE 2

Routing Table

Blk

Output

Destination

Rule

Move Logic

1

Client

Office1

FIRST 1

MOVE FOR 5

2

Client

Office2

FIRST 1

MOVE FOR 5

See Also

BEGIN, END, DO...WHILE, WHILE...DO, and DO...UNTIL.